* ==============================================================================
* ==============================================================================
* IMF Book:	IMFBOOK_Ch3_Code.do
*			Chapter 3: How to evaluate the effects of IMF conditionality
* ==============================================================================
use "IMFBOOK_Dataset.dta", clear
* ==============================================================================
* Generate variables
* ==============================================================================
encode cname, gen(cid)
xtset cid year 
gen BA1RFP = BA1FP + BA1RTP
gen BA1ENT = BA1SOE + BA1PRI
gen BA1GOV = BA1ENV + BA1INS + BA1OTH + BA1SP
foreach var of varlist BA1RFP BA1ENT BA1GOV BA1DEB BA1EXT BA1FIN BA1LAB BA1POV {
	gen `var'DUM = `var'>=1 & !missing(`var')
}
gen BA1SCOPE = BA1RFPDUM + BA1ENTDUM + BA1GOVDUM + BA1DEBDUM + BA1EXTDUM + BA1FINDUM + BA1LABDUM + BA1POVDUM
gen lnIMFliq = ln(IMFliquidity)
gen SCsBA2 = SPCsTOT + PAsTOT
gen QCsBA2 = QPCsTOT
gen BA2RFP = BA2FP + BA2RTP
gen BA2ENT = BA2SOE + BA2PRI
gen BA2GOV = BA2ENV + BA2INS + BA2OTH + BA2SP
rename ggr_ngdp_WEO govrev
rename ggx_ngdp_WEO govexp
gen govbal = govrev - govexp
egen IMFunder = sum(IMF55), by(year)
gen govheaxp = 100*ghes_per_gdp_mean_IHME
rename gini_disp_SOLT ginidisp
rename sp_dyn_imrt_in_WDI imrt
rename se_xpd_totl_gd_zs_WDI eduxp
rename sh_xpd_chex_gd_zs_WDI heaxp
gen socxp = eduxp + heaxp
* ==============================================================================
* Factual statements
* ==============================================================================
* Heterogenous programme design
list cname year BA1SCOPE BA1TOT BA2TOT BA1RFP BA1ENT BA1GOV BA1DEB BA1EXT BA1FIN BA1LAB BA1POV SCsTOT QCsTOT if cname=="Romania" & year==2004
list cname year BA1SCOPE BA1TOT BA2TOT BA1RFP BA1ENT BA1GOV BA1DEB BA1EXT BA1FIN BA1LAB BA1POV SCsTOT QCsTOT if cname=="Guatemala" & year==2004
list cname year BA1SCOPE BA1TOT BA2TOT BA1RFP BA1ENT BA1GOV BA1DEB BA1EXT BA1FIN BA1LAB BA1POV SCsTOT QCsTOT if cname=="Bosnia and Herzegovina" & year==2014
list cname year BA1SCOPE BA1TOT BA2TOT BA1RFP BA1ENT BA1GOV BA1DEB BA1EXT BA1FIN BA1LAB BA1POV SCsTOT QCsTOT if cname=="Benin" & year==2014
* Matching methods
list cname year IMFnn govbal if year>=2000 & (cname=="Uganda" | cname=="Tanzania" | cname=="Kenya" | cname=="Rwanda")
* Average level of social spending
tabstat socxp if IMF55==1 & year==2000, s(n mean)
tabstat socxp if IMF55==0 & year==2000, s(n mean)
* ==============================================================================
* Figure 3.1. IMF liquidity ratio, 1995-2019
* ==============================================================================
twoway scatter lnIMFliq year if year>=1995 & year<=2019, sort(year) connect(l) msymbol(i) graphregion(color(white)) ytitle("Natural log of IMF liquidity ratio") ylabel(, angle(horizontal)) scheme(s2mono)
graph export "Figures\IMFBOOK_Figure3-1.png", replace width(4000)
* ==============================================================================
* Figure 3.2. Parallel trends in IMF programme participation instrument
* ==============================================================================
preserve
egen nimf=sum(IMF55), by(cid)
drop if nimf==0 | year<1995
su nimf, d
g imfhigh=(nimf>`r(p50)')
collapse (mean) lnIMFliq IMFunder IMF55 BA2TOT govheaxp ginidisp imrt, by(year imfhigh)
reshape wide lnIMFliq IMFunder IMF55 BA2TOT govheaxp ginidisp imrt, i(year) j(imfhigh)
line IMF551 IMF550 year, lpattern(solid dash) yaxis(1) ytitle("Probability of IMF participation") lwidth(thick thick) ylabel(0(.2)1, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity") cols(3)) graphregion(color(white)) t1title("IMF participation") name(g1)
line govheaxp1 govheaxp0 year, lpattern(solid dash) yaxis(1) ytitle("Government health spending (% of GDP)") lwidth(thick thick) ylabel(0(1)4, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Health expenditure") name(g2)
line ginidisp1 ginidisp0 year if year<=2018, lpattern(solid dash) yaxis(1) ytitle("Gini in disposable income") lwidth(thick thick) ylabel(34(2)44, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Income inequality") name(g3)
line imrt1 imrt0 year, lpattern(solid dash) yaxis(1) ytitle("Infant mortality (per 1,000 live births)") lwidth(thick thick) ylabel(, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Health outcomes") name(g4)
grc1leg2 g1 g2 g3 g4, legendfrom(g1) xcommon iscale(0.5) lsize(vsmall) graphregion(color(white)) scheme(s2mono)
graph export "Figures\IMFBOOK_Figure3-2.png", replace width(4000)
graph drop _all
restore
* ==============================================================================
* Figure 3.3 Parallel trends in IMF conditionality instrument
* ==============================================================================
preserve
egen expBA=mean(BA2TOT), by(cid)
drop if expBA==0 | year<1995
su expBA, d
g highBA=(expBA>`r(p50)')
collapse (mean) lnIMFliq IMFunder IMF55 BA2TOT govheaxp ginidisp imrt, by(year highBA)
reshape wide lnIMFliq IMFunder IMF55 BA2TOT govheaxp ginidisp imrt, i(year) j(highBA)
line BA2TOT1 BA2TOT0 year, lpattern(solid dash) yaxis(1) ytitle("Mean number of conditions") lwidth(thick thick) ylabel(0(5)25, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity") cols(3)) graphregion(color(white)) t1title("IMF conditionality") name(g1)
line govheaxp1 govheaxp0 year, lpattern(solid dash) yaxis(1) ytitle("Government health spending (% of GDP)") lwidth(thick thick) ylabel(0(1)4, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Health expenditure") name(g2)
line ginidisp1 ginidisp0 year if year<=2018, lpattern(solid dash) yaxis(1) ytitle("Gini in disposable income") lwidth(thick thick) ylabel(34(2)44, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Income inequality") name(g3)
line imrt1 imrt0 year, lpattern(solid dash) yaxis(1) ytitle("Infant mortality (per 1,000 live births)") lwidth(thick thick) ylabel(, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Health outcomes") name(g4)
grc1leg2 g1 g2 g3 g4, legendfrom(g1) xcommon iscale(0.5) lsize(vsmall) graphregion(color(white)) scheme(s2mono)
graph export "Figures\IMFBOOK_Figure3-3.png", replace width(4000)
graph drop _all
restore
* ==============================================================================
* Supplementary statistical code. Parallel trends in disaggregated IMF conditionality instruments
* ==============================================================================
foreach var of varlist QCsBA2 SCsBA2 BA2DEB BA2FIN BA2RFP BA2EXT BA2ENT BA2LAB BA2GOV {
	preserve
	egen expBA=mean(`var'), by(cid)
	drop if expBA==0 | year<1995
	su expBA, d
	g highBA=(expBA>`r(p50)')
	collapse (mean) lnIMFliq IMFunder IMF55 `var' govheaxp ginidisp imrt, by(year highBA)
	reshape wide lnIMFliq IMFunder IMF55 `var' govheaxp ginidisp imrt , i(year) j(highBA)
	line `var'1 `var'0 year, lpattern(solid dash) yaxis(1) ytitle("Mean number of conditions") lwidth(thick thick) ylabel(0(5)25, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity") cols(3)) graphregion(color(white)) t1title("IMF conditionality") name(g1)
	line govheaxp1 govheaxp0 year, lpattern(solid dash) yaxis(1) ytitle("Government health spending (% of GDP)") lwidth(thick thick) ylabel(0(1)4, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Health expenditure") name(g2)
	line ginidisp1 ginidisp0 year if year<=2018, lpattern(solid dash) yaxis(1) ytitle("Gini in disposable income") lwidth(thick thick) ylabel(34(2)44, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Income inequality") name(g3)
	line imrt1 imrt0 year, lpattern(solid dash) yaxis(1) ytitle("Infant mortality (per 1,000 live births)") lwidth(thick thick) ylabel(, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Health outcomes") name(g4)
	grc1leg2 g1 g2 g3 g4, legendfrom(g1) xcommon iscale(0.5) lsize(vsmall) graphregion(color(white)) scheme(s2mono)
	*** graph export "Figures\IMFBOOK_Figure3-SSC_Parallel_Trends_`var'.png", replace width(4000)
	graph drop _all
	restore
}
* BA2POV uses above/below mean for high/low groupings rather than median, as all values for countries with BA2POV are equal to or above the median
preserve
egen expBA=mean(BA2POV), by(cid)
drop if expBA==0 | year<1995
su expBA, d
g highBA=(expBA>`r(mean)')
collapse (mean) lnIMFliq IMFunder IMF55 BA2POV govheaxp ginidisp imrt , by(year highBA)
reshape wide lnIMFliq IMFunder IMF55 BA2POV govheaxp ginidisp imrt, i(year) j(highBA)
line BA2POV1 BA2POV0 year, lpattern(solid dash) yaxis(1) ytitle("Mean number of conditions") lwidth(thick thick) ylabel(0(5)25, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity") cols(3)) graphregion(color(white)) t1title("IMF conditionality") name(g1)
line govheaxp1 govheaxp0 year, lpattern(solid dash) yaxis(1) ytitle("Government health spending (% of GDP)") lwidth(thick thick) ylabel(0(1)4, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Health expenditure") name(g2)
line ginidisp1 ginidisp0 year if year<=2018, lpattern(solid dash) yaxis(1) ytitle("Gini in disposable income") lwidth(thick thick) ylabel(34(2)44, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Income inequality") name(g3)
line imrt1 imrt0 year, lpattern(solid dash) yaxis(1) ytitle("Infant mortality (per 1,000 live births)") lwidth(thick thick) ylabel(, angle(0)) || line lnIMFliq1 year, lpattern(shortdash_dot) yaxis(2) ytitle("Natural log of IMF liquidity ratio", axis(2)) ylabel(, angle(0) axis(2)) xlabel(1995(5)2020) legend(label(1 "Above-mean exposure") label(2 "Below-mean exposure") label(3 "IMF liquidity")) graphregion(color(white)) t1title("Health outcomes") name(g4)
grc1leg2 g1 g2 g3 g4, legendfrom(g1) xcommon iscale(0.5) lsize(vsmall) graphregion(color(white)) scheme(s2mono)
***	graph export "Figures\IMFBOOK_Figure3-SSC_Parallel_Trends_BA2POV.png", replace width(4000)
graph drop _all
restore
* ==============================================================================
